# -*- coding: utf-8 -*-
# @Author   : Claus
# @Time     : 2020/6/30 17:12
# @FileName : 连接redis - 3.py
import time
from redis import StrictRedis


'''
    一般连接，使用StrictRedis连接
'''


start = time.time()
# 这里使用StrictRedis
db = StrictRedis(host="localhost", port=6379, db=0, decode_responses=True)
for i in range(100000):
    # 添加成功返回1，否则返回0，类型是int
    resu = db.sadd("Claus", f"python - {i}")
    if resu == 1:
        print("添加成功")
    else:
        print("数据已存在")

end = time.time()
print(f"用时: {end - start}")
